home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-02-14 | 9.7 KB | 443 lines | [TEXT/ALFA] |
- # 'pete' is used in the rest of the file to determine if this is we
- # are sitting on someone else's disk.
- set pete [expr [file exists "Internal:C:Alpha:Alpha"]?1:0]
- set Tcl [expr {$pete ? {Internal:C:Alpha:Tcl 6.2} : "$HOME"}]
-
- #===============================================================================================
- # Appends all the 'noGlobNecessary' elements with globs of 'globNecessary' elements to create
- # the penultimate list file sets. Also calls Alpha and tells it the new list of file set names.
- # It is easy to create large filesets by using the 'glob' Tcl command. All that is really
- # necessary is to provide Alpha with a list of fileset names and a way to retrieve the contents
- # of a given fileset.
- #===============================================================================================
-
- if ($pete) {
- addMenuItem Misc "(-"
- addMenuItem Misc createStuffitArchive
- addMenuItem Misc backupSource
- set globNecessary {
- {Edit "$HOME:EditSource:*.c"}}
- set noGlobNecessary {
- { Alpha
- "$HOME:EditSource:emacs.c"
- "$HOME:EditSource:dir.c"
- "$HOME:EditSource:alloca.c"
- "$HOME:EditSource:bindings.c"
- "$HOME:EditSource:command.c"
- "$HOME:EditSource:file_set.c"
- "$HOME:EditSource:search.c"
- "$HOME:EditSource:text.c"
- "$HOME:EditSource:undo.c"
- "$HOME:EditSource:varargs.c"
- "$HOME:EditSource:windows.c"
- "$HOME:EditSource:dirT.c"
- "$HOME:EditSource:frills.c"
- "$HOME:EditSource:io.c"
- "$HOME:EditSource:key.c"
- "$HOME:EditSource:localTcl.c"
- "$HOME:EditSource:moreTcl.c"
- "$HOME:EditSource:shell.c"
- "$HOME:EditSource:main.c"
- "$HOME:EditSource:misc.c"
- "$HOME:EditSource:options.c"
- "$HOME:EditSource:port.c"
- "$HOME:EditSource:redraw.c"
- "$HOME:EditSource:alfRegexp.c"
- "$HOME:EditSource:wmanager.c"
- "$Tcl:panic.c"
- "$Tcl:tclMac.c"
- "$Tcl:tclMacUtil.c"
- "$Tcl:tclAssem.c"
- "$Tcl:tclBasic.c"
- "$Tcl:tclCkalloc.c"
- "$Tcl:tclCmdAH.c"
- "$Tcl:tclCmdIL.c"
- "$Tcl:tclCmdMZ.c"
- "$Tcl:tclEnv.c"
- "$Tcl:tclExpr.c"
- "$Tcl:tclGet.c"
- "$Tcl:tclGlob.c"
- "$Tcl:tclHash.c"
- "$Tcl:tclHistory.c"
- "$Tcl:tclParse.c"
- "$Tcl:tclProc.c"
- "$Tcl:tclUnixAZ.c"
- "$Tcl:tclUnixStr.c"
- "$Tcl:tclUnixUtil.c"
- "$Tcl:tclUtil.c"
- "$Tcl:tclVar.c"
- }
- }
- } else {
- set globNecessary {
- {HomeDir "$HOME:*"}
- {Help "$HOME:Help:*"}
- }
-
- set noGlobNecessary {
- { AlternateHome
- "$HOME:AlphaBits.tcl"
- "$HOME:procs.tcl"}
- { AlternateHelp
- "Alpha Help"
- "Alpha Tcl Extensions"
- "Debugging"
- "keyboard.tex"
- "LaTeX Keys"
- "Regular Expressions"
- "Shells"
- "Tcl"
- }
- }
- }
-
- # This list takes a string and returns the string w/ all occurances
- # of the variable 'HOME' substituted. To work this trick w/ other
- # variables, just declare them as global in the following.
- # This routine creates the final fileset list from 'globNecessary'
- # 'noGlobNecessary'. Typically only run at startup.
- proc expandFileSets {} {
- global fileSets
- global fileSetNames
- global currFileSet
- global globNecessary
- global noGlobNecessary
-
- uplevel #0 {set globNecessary [substituteVars $globNecessary]}
- uplevel #0 {set noGlobNecessary [substituteVars $noGlobNecessary]}
-
- set fileSets {}
- set fileSetNames {}
-
- foreach item $globNecessary {
- lappend fileSets [linsert [glob [lindex $item 1]] 0 [lindex $item 0]]
- lappend fileSetNames [lindex $item 0]
- }
- foreach item $noGlobNecessary {
- lappend fileSets $item
- lappend fileSetNames [lindex $item 0]
- }
-
- menu -n fileSets -m -p changeFileSet $fileSetNames
- if {[catch {[set currFileSet]}] == "1"} {
- set currFileSet [lindex $fileSetNames 0]
- }
- }
- if {[catch expandFileSets]} {alertnote "Fileset expansion went wrong."}
-
- # Called from Alpha to get list of files for current file set.
- proc getCurrFileSet {} {
- global fileSets
- global currFileSet
- foreach set $fileSets {
- if {$currFileSet == [lindex $set 0]} {
- return [lrange $set 1 end]
- }
- }
- error "Unable to find valid file set!"
- }
-
- # Called from Alpha to get names.
- proc getFileSetNames {} {
- global fileSetNames
- return $fileSetNames
- }
-
- #==============================================================================
- proc normalLeftBracket {} {
- insertText "\{"
- }
- proc normalRightBracket {} {
- insertText "\}"
- }
- bind '\[' <zs> normalLeftBracket
- bind '\]' <zs> normalRightBracket
- #==============================================================================
-
-
- # Select the next or current word. If word already selected, will go to next.
- proc hiliteWord {} {
- if {[getPos]!=[selEnd]} forwardChar
- forwardWord
- set start [getPos]
- backwardWord
- select $start [getPos]
- }
-
- bind 'h' <z> hiliteWord
-
- # For mark stack.
- set markName 0
- set markStack ""
-
-
- #=============================================================================
- # Hook procs recognized: "openHook", "closeHook", "activateHook", "deactivateHook",
- # "suspendHook", and "resumeHook".
- #=============================================================================
-
- # Event hooks - set specific modes when files opened.
- proc openHook name {
- hookMode $name
- if {$name == {*mpw shell*}} startMPW
- addWinName $name
- }
-
- # Clean up the mark stack.
- proc closeHook name {
- global markStack
- if [llength $markStack] {
- set markStack [removePat $markStack $name*]
- }
- removeWinName $name
- }
-
- proc saveasHook {oldName newName} {
- removeWinName $oldName
- addWinName $newName
- }
-
-
- proc activateHook name {
- hookMode $name
- }
-
- proc hookMode name {
- case $name in {
- "*.c" setCMode
- "*.cc" setC++Mode
- "*.C" setC++Mode
- "*.h" setCMode
- "*.f" setFortranMode
- "*.tcl" setTclMode
- {*mpw\ sh*} setMPWMode
- {*tcl\ sh*} setShellMode
- "*.tex" setTexMode
- "*.sty" setTexMode
- default setTextMode
- }
- }
-
-
- # 'modes' is inspected by alpha for the popup mode menu. 'newMode' is
- # called by Alpha in case of a successful choice.
- set modes { C C++ Csh Fort MPW Tcl Tex Text }
- proc newMode mode {
- case $mode in {
- "C" setCMode
- "C++" setC++Mode
- "Csh" setShellMode
- "Fort" setFortranMode
- "MPW" setMPWMode
- "Tcl" setTclMode
- "Tex" setTexMode
- "Text" setTextMode
- }
- }
-
-
- proc deactivateHook name {
- }
-
- proc suspendHook name {
- global iconifyOnSwitch
- global suspIconed
- if {$iconifyOnSwitch} {
- set wins [winNames -f]
- foreach win $wins {
- if {![icon -f "$win" -q]} {
- set suspIconed($win) 1
- icon -f "$win" -t
- }
- }
- }
- }
-
- proc resumeHook name {
- global iconifyOnSwitch
- global suspIconed
- if {$iconifyOnSwitch && [info exists suspIconed]} {
- set wins [winNames -f]
- foreach win [array names suspIconed] {
- icon -f "$win" -o
- }
- unset suspIconed
- }
- }
-
- # Handles dynamically adding and deleting window names from menu.
- proc addWinName name {
- global winNameToNum
- global winNumToName
- global fullNames
-
- for {set i 0} {$i<100} {incr i} {
- if {[catch {set nm $winNumToName($i)} res] == "1"} {
- if {$fullNames != "0"} {
- set nm $name
- } else {
- regexp {[^:]*$} $name nm
- }
- if {$i < 10} {
- addMenuItem -m -l "/$i" Wins $nm
- } else {
- addMenuItem -m -l "" Wins $nm
- }
- set winNumToName($i) $name
- set winNameToNum($name) $i
- return
- }
- }
- }
-
- proc removeWinName name {
- global winNameToNum
- global winNumToName
- global fullNames
-
- set num $winNameToNum($name)
- unset winNumToName($num)
- unset winNameToNum($name)
- if {$fullNames == "1"} {
- deleteMenuItem -m Wins $name
- } else {
- regexp {[^:]*$} $name nm
- deleteMenuItem -m Wins $nm
- }
- }
-
-
- proc menuWin {menu name} {
- global winNameToNum
-
- set nms [array names winNameToNum]
- foreach nm $nms {
- if {[string match *$name $nm] == "1"} {
- bringToFront $name
- if [icon -q] { icon -f $name -o }
- return
- }
- }
- return "normal"
- }
-
-
- set lastMode 0
-
- # rta Creating texWasLast variable
- set texWasLast 0
- # rta Following changed from ThinkC to MPW
-
-
- # Modes
-
- # Fortran programming mode
- proc setFortranMode {} {
- changeMode "Fort"
- uplevel #0 {
- set elecLBrace 0
- set elecRBrace 0
- set electricSemi 0
- set wordWrap 0
- set funcExpr {^( |\t)(subroutine|.*function|SUBROUTINE|.*FUNCTION).*\(.*$}
- set sortedIsDefault 0
- set funcTitle "Func"
- }
- }
-
-
- # Alpha TCL programming mode
- menu -n Tcl {
- "traceTclProc"
- "traceOff"
- }
-
- # LaTeX mode
- proc setTexMode {} {
- changeMode "Tex"
- uplevel #0 {
- set wordBreakPreface {[^a-zA-Z0-9_]}
- set wordBreak {[a-zA-Z0-9_]+}
- set elecLBrace 0
- set elecRBrace 0
- set electricSemi 0
- set wordWrap 1
- set fillColumn 75
- set prefixString "% "
- set funcTitle "Sect"
- set sortedIsDefault 0
- set funcExpr {^\\(sub)*section\*?{([^{}]*)}}
- # set funcExpr {^\\(sub)*section\*?{(.*)}$}
- set funcPar 2
- set savedIsMeta $optionIsMeta
- # Comment out next line (put "#" in column 0) to use option key
- # as meta and bind LaTeX macros to option-control in Tex mode.
- if {!$pete} {set optionIsMeta 0}
- # Next is a call to a random proc in the latex file to make sure
- # is it auto-loaded.
- isSelection
- insertMenu "LaTeX"
- }
- }
-
-
- # Ordinary, default mode
- proc setTextMode {} {
- changeMode "Text"
- uplevel #0 {
- set elecLBrace 0
- set elecRBrace 0
- set electricSemi 0
- set wordWrap 1
- set fillColumn 75
- set prefixString "> "
- set suffixString " <--"
- }
- }
-
-
- proc changeMode {newMode} {
- global lastMode
- global savedIsMeta
- global wordBreak
- global wordBreakPreface
- global optionIsMeta
-
- if {$lastMode == $newMode} {
- displayMode $newMode
- return
- }
-
- displayMode $newMode
- case $lastMode in {
- "Tex" {
- set optionIsMeta $savedIsMeta
- set wordBreakPreface {[^a-zA-Z0-9_]}
- set wordBreak {[a-zA-Z0-9_]+}
- set wordBreak {[a-zA-Z0-9_]+}
- removeMenu "LaTeX"
- set optionIsMeta 1
- }
- "Tcl" {
- removeMenu "Tcl"
- }
- }
- if {[string length $lastMode]} {enableMenuItem Modes $lastMode on}
- enableMenuItem Modes $newMode off
- global mode
- set mode $newMode
- set lastMode $newMode
- }
-
-
- proc alphaHelp {} {
- global HOME
- edit -r -m "$HOME:Help:Alpha Help"
- }
-
-
- set patternLibrary {
- { "Pascal to C Comments" {\{([^\}]*)\}} {/* \1 */} }
- { "C++ to C Comments" {//(.*)} {/* \1 */}}
- }
-